﻿using System;

namespace Poly2Tri
{
	// Token: 0x02000410 RID: 1040
	public class MathUtil
	{
		// Token: 0x06001D0A RID: 7434 RVA: 0x000B44B8 File Offset: 0x000B26B8
		public static bool AreValuesEqual(double val1, double val2)
		{
			return MathUtil.AreValuesEqual(val1, val2, MathUtil.EPSILON);
		}

		// Token: 0x06001D0B RID: 7435 RVA: 0x000B44C6 File Offset: 0x000B26C6
		public static bool AreValuesEqual(double val1, double val2, double tolerance)
		{
			return val1 >= val2 - tolerance && val1 <= val2 + tolerance;
		}

		// Token: 0x06001D0C RID: 7436 RVA: 0x000B44E0 File Offset: 0x000B26E0
		public static bool IsValueBetween(double val, double min, double max, double tolerance)
		{
			if (min > max)
			{
				double num = min;
				min = max;
				max = num;
			}
			return val + tolerance >= min && val - tolerance <= max;
		}

		// Token: 0x06001D0D RID: 7437 RVA: 0x000B4514 File Offset: 0x000B2714
		public static double RoundWithPrecision(double f, double precision)
		{
			if (precision < 0.0)
			{
				return f;
			}
			double num = Math.Pow(10.0, precision);
			return Math.Floor(f * num) / num;
		}

		// Token: 0x06001D0E RID: 7438 RVA: 0x000B454E File Offset: 0x000B274E
		public static double Clamp(double a, double low, double high)
		{
			return Math.Max(low, Math.Min(a, high));
		}

		// Token: 0x06001D0F RID: 7439 RVA: 0x000B4560 File Offset: 0x000B2760
		public static void Swap<T>(ref T a, ref T b)
		{
			T t = a;
			a = b;
			b = t;
		}

		// Token: 0x06001D10 RID: 7440 RVA: 0x000B4588 File Offset: 0x000B2788
		public static uint Jenkins32Hash(byte[] data, uint nInitialValue)
		{
			foreach (byte b in data)
			{
				nInitialValue += (uint)b;
				nInitialValue += nInitialValue << 10;
				nInitialValue += nInitialValue >> 6;
			}
			nInitialValue += nInitialValue << 3;
			nInitialValue ^= nInitialValue >> 11;
			nInitialValue += nInitialValue << 15;
			return nInitialValue;
		}

		// Token: 0x04001DC0 RID: 7616
		public static double EPSILON = 1E-12;
	}
}
